package com.ossjk.oa.config.mvc;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.ossjk.core.util.CommonUtil;
import com.ossjk.oa.advisory.entity.Customer;
import com.ossjk.oa.advisory.service.ICustomerService;

@Component
public class Scheduler {
	@Autowired
	private ICustomerService iCustomerService;

	// 每天0点执行
	@Scheduled(cron = "0 0 0 ? * *")
	public void testTasks1() {
		Wrapper wrapper = Condition.create().isWhere(true).isNotNull("mtime").ne("c.isdelete", 2).lt("mtime", CommonUtil.plus(CommonUtil.date0(), -3, "MONTHS")).isNotNull("c.eid");
		List<Customer> list = iCustomerService.selectLastFollow(wrapper);
		if (!list.isEmpty()) {
			for (Customer customer : list) {
				customer.setEid(null);
			}
			iCustomerService.updateAllColumnBatchById(list);
		}
	}

}